<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert Times</title>
<SCRIPT type="text/javascript"
	src="http://code.jquery.com/jquery-1.6.4.min.js"></SCRIPT>

</head>
<body>
	<h1>Enter in your available times</h1>
	<f:view>
		<h:messages layout="table"></h:messages>

		<h:form>
			<h:commandLink binding="#{pleaseWork.addCommand }" accesskey="n"
				action="#{pleaseWork.addNew }" value="Add new Time"></h:commandLink>
		</h:form>

		<h:form binding="#{pleaseWork.form }" rendered="false">
			<h:panelGrid columns="3">
				Start Time
				<h:selectOneMenu id="selectStartHr" value="#{pleaseWork.currentStartHour}">
					<f:selectItems id="startHrs" value="#{pleaseWork.hourList}" />
				</h:selectOneMenu>
				<h:selectOneMenu id="selectStartMin" value="#{pleaseWork.currentStartMin}">
					<f:selectItems id="startMins" value="#{pleaseWork.minList}" />
				</h:selectOneMenu>
			</h:panelGrid>
			<h:panelGrid columns="3">
				End Time
				<h:selectOneMenu id="selectEndHr" value="#{pleaseWork.currentEndHour}">
					<f:selectItems id="endHrs" value="#{pleaseWork.hourList}" />
				</h:selectOneMenu>
				<h:selectOneMenu id="selectEndMin" value="#{pleaseWork.currentEndMin}">
					<f:selectItems id="endMins" value="#{pleaseWork.minList}" />
				</h:selectOneMenu>
			</h:panelGrid>
			<h:panelGrid columns="3" style="width: 403px; ">
				Week/Day
				<h:selectOneMenu id="selectWeek" value="#{pleaseWork.currentWeek }">
					<f:selectItems id="weeks" value="#{pleaseWork.weekOfSemester }"></f:selectItems>
				</h:selectOneMenu>
				<h:selectOneMenu id="selectDay" value="#{pleaseWork.currentDay }">
					<f:selectItems id="days" value="#{pleaseWork.daysOfWeek }"></f:selectItems>
				</h:selectOneMenu>				
			</h:panelGrid><h:panelGroup>
				<h:commandButton action="#{pleaseWork.save }" value="Save" accesskey="s" id="saveButton"></h:commandButton>
				<h:commandButton action="#{pleaseWork.cancel }" value="Cancel" accesskey="c" immediate="true"></h:commandButton>
			</h:panelGroup>
			

		</h:form>
		<h:form>
			<h:panelGrid columns="2">
				<h:commandLink id="hide" actionListener="#{pleaseWork.displayTable}"
					value="Hide Table">
				</h:commandLink>
				<h:commandLink id="show" actionListener="#{pleaseWork.displayTable}"
					value="Show Table">
				</h:commandLink>
			</h:panelGrid>
		</h:form>
		
		
		<h:form binding="#{pleaseWork.tableForm}">

			<h:dataTable value="#{pleaseWork.allTimes}" var="allTimes"				
				columnClasses="first, rest">
				<h:column>
					<f:facet name="header">
						<h:column>
							<h:outputText value="Week"></h:outputText>
						</h:column>
					</f:facet>
					<h:outputText value="#{allTimes.currentWeek}"></h:outputText>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:column>
							<h:outputText value="Day"></h:outputText>
						</h:column>
					</f:facet>
					<h:outputText value="#{allTimes.currentDay}"></h:outputText>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:column>
							<h:outputText value="Start Time"></h:outputText>
						</h:column>
					</f:facet>
					<h:outputText value="#{allTimes.startHr}"></h:outputText>&nbsp
					<h:outputText value="#{allTimes.startMin }"></h:outputText>

				</h:column>

				<h:column>
					<f:facet name="header">
						<h:column>
							<h:outputText value="End Time"></h:outputText>
						</h:column>
					</f:facet>
					<h:outputText value="#{allTimes.endHr}"></h:outputText>&nbsp
					<h:outputText value="#{allTimes.endMin}"></h:outputText>
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:column>
							<h:outputText value="Actions"></h:outputText>
						</h:column>
					</f:facet>
					<h:panelGrid columns="2">
<!-- 					May need to create a current inputTime object for these properties -->
						<h:commandLink value="delete" action="#{pleaseWork.delete}">
							<f:setPropertyActionListener target="#{pleaseWork.addedTime}"
  								value="#{allTimes}" />  
 						</h:commandLink> 
 					</h:panelGrid> 
 				</h:column>
 			</h:dataTable> 
				<h:commandButton action="#{pleaseWork.submit }" value="Submit Times" 
					accesskey="b" immediate="true">
				</h:commandButton>
 		</h:form> 
	</f:view>

</body>
</html>